package top.shenluw.springdemo.webflux;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @author Shenluw
 * 创建日期：2019/1/22 14:45
 */
@RestController
@RequestMapping("/rest")
public class TestRestController {
    @GetMapping("/{id}")
    public Mono<User> getUser(@PathVariable("id") Integer id) {
        User user = new User();
        user.setId(id);
        return Mono.just(user);
    }

    @GetMapping
    public Flux<User> getUserFlux(Integer id) {
        User user = new User();
        user.setId(id);
        return Flux.just(user);
    }

}
